import 'dart:convert' show json;

import 'package:flutter/cupertino.dart';
import 'package:freedom/entity/user_entity_info.dart';

import 'package:freedom/util/data_type.dart';

class MetaUserChannel with ChangeNotifier {
  String? userId;
  bool? banker;
  int? seq;
  bool? win;
  bool? online;
  SysUser? sysUser;

  MetaUserChannel(
      {this.userId,
      this.banker,
      this.seq,
      this.win,
      this.online,
      this.sysUser});

  Map<String, dynamic> toJson() => <String, dynamic>{
        'userId': userId,
        'banker': banker,
        'seq': seq,
        'win': win,
        'online': online,
        'sysUser': sysUser
      };

  factory MetaUserChannel.fromJson(Map<String, dynamic> jsonRes) =>
      MetaUserChannel(
        userId: asT<String>(jsonRes['userId']),
        banker: asT<bool>(jsonRes['banker']),
        seq: asT<int>(jsonRes['seq']),
        win: asT<bool>(jsonRes['win']),
        online: asT<bool>(jsonRes['online']),
        sysUser: SysUser.fromJson((jsonRes)['sysUser']),
      );

  @override
  String toString() {
    return json.encode(this);
  }
}
